<!DOCTYPE html>
<html lang="ch">
<head>
    <meta charset="UTF-8">
    <title>test</title>
    <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
    <link rel="icon" href="img/web_icon.png">
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/show-code.css">
    <script>
        var id = getQueryVariable("codeId")
        if (id === null) {
            location.replace('/404.html')
        }
        showOnPage()

        function getQueryVariable(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        }

        function showOnPage() {
            $.ajax({
                type: "post",
                url: "/code/show-one",
                data: "codeId=" + id,
                dataType: "text json",
                statusCode: {
                    200: function (data) {
                        if (data.codeId === undefined) {
                            alert("没有这段代码")
                        } else {
                            $("#title-div").append(data.title)
                            $("#code-textarea").val(
                                "\n/**" +
                                "\n/* @version: " + data.version +
                                "\n/* @lastUpdateTime: " + data.lastUpdateDate +
                                "\n/**\n\n" + data.code
                            )
                            $("#label-div").append("关键词：" + data.labels)
                            $("#resume-textarea").val(data.resume)
                        }
                    }
                }
            })
        }
    </script>
</head>
<body>

<div class="left-right">
    <div class="ava-div">
        <a href="/"><img src="img/ava_icon.png"></a>
    </div>
    <div class="title-div" id="title-div"></div>
    <div class="label-div" id="label-div"></div>
    <div class="resume-div">
        <textarea disabled id="resume-textarea"></textarea>
    </div>
    <div class="exit-update-line">
        <div class="exit-update-div"></div>
        <div class="exit-update-div"></div>
        <div class="exit-update-div">
            <input type="submit" value="删除" id="delete">
        </div>
        <div class="exit-update-div">
            <input type="submit" value="修改" id="update">
        </div>
    </div>
</div>
<div class="mid-div">
    <div class="mid-white"></div>
    <div class="mid-gray"></div>
    <div class="mid-white"></div>
</div>
<div class="left-right">
    <textarea disabled id="code-textarea"></textarea>
</div>
</body>
</html>